ProjectName.modules.Banner = {
    init: function () {
        
        this.formValidation();
        this.deleteBannerDefaultImage();
        this.initDatePicker();
        this.initLightBox();
    } ,
    initLightBox : function (){
    	$('.lightbox').lightBox();
    },
    
    initDatePicker : function () {
      var datepickerPath = 'images/datepickericon.png';
	$("#addeddate").datepicker({
	    firstDay: 1 ,
	    showOn: 'both',
	    buttonImage: datepickerPath ,
	    buttonImageOnly: true,
	    dateFormat: 'yy-mm-dd'
	});
	
	
	
	
    },
    deleteBannerDefaultImage: function (){
        $('.image-delete').click(function(){
			var bool = confirm("Are you sure you want to edit this image? Editing this image will delete it and you would need to add a new image");
            if (bool) {
                var click = $(this);
                var bannerId = $(this).attr('id');
                bannerId = jQuery.trim(bannerId);
                var filename = $(this).attr('name');
                filename = jQuery.trim(filename);
                var postdata = {};
                postdata['bannerid'] = bannerId;
                postdata['filename'] = filename;
                postdata['callback'] = 'bannerImageDelete';
                jQuery.post ( base_url+'admingeneral.ajax.php' , postdata , function (result){
                    jQuery('#upload-image-container').show();
                    click.parents('.image-container').html('');
                    window.location.href=window.location.href;
                });
            }
            return false;
        });
    },
    formValidation : function () {
        var container = $('div.pageerrorcontainer-validator');
        $("#bannerfrm").validate({
            errorContainer: container,
            errorLabelContainer: $("div.error-iterator", container),
            wrapper: 'div',
            rules: {
                title: {
                    required: true
                },				description: {                    required: true                },				link: {                    url: true                }
            },
            messages: {
                title: {
                    required: "Please enter title."
                },				description: {                    required: "Please enter description"                },				link: {                    url: "Link is not valid url"                }
            }
        });
    } 
}
